package com.fs.pojo;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

/**
 * @author hyy
 * @version 1.0
 * @description: 销售订单信息封装
 * @date 2024/10/15 10:26
 */
@Data
public class Order {
    //订单Id
    @TableId(type = IdType.AUTO)
    private Integer orderId;
    //顾客Id
    private Integer customerId;
    //订单完成时间
    @JsonFormat(shape= JsonFormat.Shape.STRING,pattern = "yyyy-MM-dd")   //json格式数据里面日期类型的转换
    @DateTimeFormat(pattern = "yyyy-MM-dd")  //提交请求日期格式的转换
    private Date orderDate;
    //订单送货地址
    private String shoppingAddress;
    //订单状态——0~3表示待发货、已发货、已完成、退货
    private Integer orderStatus;
    //销售人员id
    private Integer salespersonId;
    //创建订单时间
    @JsonFormat(shape= JsonFormat.Shape.STRING,pattern = "yyyy-MM-dd")   //json格式数据里面日期类型的转换
    @DateTimeFormat(pattern = "yyyy-MM-dd")  //提交请求日期格式的转换
    private Date createTime;
    //相关订单详情
    @TableField(exist = false)
    private List<OrderDetails> orderDetails;
    //销售人员外键
    @TableField(exist = false)
    private User salesPerson;
    //销售人员外键
    @TableField(exist = false)
    private Customer customer;
    @TableField(exist = false)
    private String searchTime;

    public String getsearchTime() {
        if (createTime == null) {
            return null; // 或者返回一个默认值，如空字符串 ""
        }
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
        return dateFormat.format(createTime);
    }


}
